package javabase.schoolwork.day6_1to3;



/**
 * @author fance
 * @date 2018/5/29 10:13
 */
public class CheckingAccount extends Account {
    private double overdraftProtection;

    public CheckingAccount(double init_balance) {
        super(init_balance);
    }

    public CheckingAccount(double init_balance, double overdraftProtection) {
        super(init_balance);
        this.overdraftProtection = overdraftProtection;
    }

    @Override
    public boolean withdaw(double money) {
        if (money >= balance) {
            balance -= money;
            return true;
        } else  if (overdraftProtection >= (balance - money)) {
            balance -= money;
            balance -= overdraftProtection;
            return true;
        }
        return false;
    }

    public static void main(String[] args) {
        //Account account = new Account(10);
        CheckingAccount checkingAccount = new CheckingAccount(10,10);
        checkingAccount.withdaw(15);
        System.out.println(checkingAccount.balance);
    }
}
